package org.zuel.boot.demo.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.zuel.boot.demo.entity.Employment;
import org.zuel.boot.demo.entity.SysUser;
import org.zuel.boot.demo.service.IEmploymentService;
import org.zuel.boot.demo.service.impl.SessionService;
import org.zuel.boot.demo.web.JsonResult;
import org.zuel.boot.demo.web.PageParam;

import javax.servlet.http.HttpServletRequest;

/**
 *  控制器
 *
 * @author ikun
 */
@Api(tags = "管理")
@RestController
@RequestMapping("/zuel")
public class EmploymentController{
    @Autowired
    private SessionService sessionService;
    private IEmploymentService employmentService;

    @Autowired
    public EmploymentController(IEmploymentService employmentService){
        this.employmentService = employmentService;
    }

    @ApiOperation("查询个人")
    @GetMapping("/employment/list1")
    public IPage<Employment> list1(HttpServletRequest request) {
        PageParam<Employment> pageParam = new PageParam<>(request);
        SysUser user = sessionService.validateSession1(request);
        return employmentService.list1(pageParam,user);
    }
    @ApiOperation("查询个人")
    @GetMapping("/employment/list2")
    public IPage<Employment> list2(HttpServletRequest request) {
        PageParam<Employment> pageParam = new PageParam<>(request);
        SysUser user = sessionService.validateSession1(request);
        return employmentService.list2(pageParam,user);
    }
    @ApiOperation("查询个人")
    @GetMapping("/employment/list3")
    public IPage<Employment> list3(HttpServletRequest request) {
        PageParam<Employment> pageParam = new PageParam<>(request);
        SysUser user = sessionService.validateSession1(request);
        return employmentService.list3(pageParam,user);
    }
    @ApiOperation("查询个人")
    @GetMapping("/employment/list11")
    public IPage<Employment> list11(HttpServletRequest request) {
        PageParam<Employment> pageParam = new PageParam<>(request);
        SysUser user = sessionService.validateSession1(request);
        return employmentService.list11(pageParam,user);
    }
    @ApiOperation("查询个人")
    @GetMapping("/employment/list21")
    public IPage<Employment> list21(HttpServletRequest request) {
        PageParam<Employment> pageParam = new PageParam<>(request);
        SysUser user = sessionService.validateSession1(request);
        return employmentService.list21(pageParam,user);
    }
    @ApiOperation("查询个人")
    @GetMapping("/employment/list31")
    public IPage<Employment> list31(HttpServletRequest request) {
        PageParam<Employment> pageParam = new PageParam<>(request);
        SysUser user = sessionService.validateSession1(request);
        return employmentService.list31(pageParam,user);
    }

    @ApiOperation("查询单个")
    @GetMapping("/employment/get/{id}")
    public JsonResult read(@PathVariable("id") Integer id) {
        return employmentService.read(id);
    }

    @ApiOperation("添加")
    @PostMapping("/employment/add")
    public JsonResult add(@RequestBody Employment model,HttpServletRequest request) {
        SysUser user = sessionService.validateSession1(request);
        return employmentService.add(model,user);
    }
    @ApiOperation("添加")
    @PostMapping("/employment/add1")
    public JsonResult add1(@RequestBody Employment model,HttpServletRequest request) {
        SysUser user = sessionService.validateSession1(request);
        return employmentService.add1(model,user);
    }

    @ApiOperation("修改")
    @PostMapping("/employment/update")
    public JsonResult update(@RequestBody Employment model) {
    return employmentService.update(model);
    }
    @ApiOperation("同意邀请")
    @PostMapping("/employment/agree")
    public JsonResult agree(@RequestBody Employment model,HttpServletRequest request) {
        return employmentService.agree(model);
    }

    @ApiOperation("删除")
    @GetMapping("/employment/delete/{ids}")
    public JsonResult delete(@PathVariable("ids") Integer[] ids) {
        return employmentService.delete(ids);
    }

}